package com.bw.sofa_module.videosofa;

import android.widget.ImageView;

import com.bw.adapter_sdk.quick.BaseQuickAdapter;
import com.bw.adapter_sdk.quick.BaseViewHolder;
import com.bw.ijk.widget.VideoView;
import com.bw.network_sdk.videoentity.VideoValuesEntity;
import com.bw.sofa_module.R;

public class VideoAdapter extends BaseQuickAdapter<VideoValuesEntity> {
    public VideoAdapter() {
        super(R.layout.item_video);
        addItemChildClick(R.id.item_video_likes_img,
                R.id.item_video_unlikes_img);
    }

    @Override
    public void convert(BaseViewHolder holder, VideoValuesEntity item) {
        holder.setText(R.id.item_video_artist,item.author.name);
        holder.setText(R.id.item_video_content,item.feeds_text);
        holder.setText(R.id.item_video_likes_count,item.ugc.likeCount+"");
        holder.setText(R.id.item_video_share_count,item.ugc.shareCount+"");
        holder.setText(R.id.item_video_comment_count,item.ugc.commentCount+"");

        holder.setCirImage(R.id.item_video_artist_img,item.author.avatar);

        VideoView videoView = holder.getView(R.id.item_video_ijkview);
        videoView.setPlayUrl(item.url,item.cover);

        ImageView image_like = holder.getView(R.id.item_video_likes_img);
        ImageView image_diss = holder.getView(R.id.item_video_unlikes_img);

        if (item.ugc.hasLiked)
            image_like.setImageResource(R.drawable.icon_cell_liked);
        else
            image_like.setImageResource(R.drawable.icon_cell_like);

        if (item.ugc.hasdiss)
            image_diss.setImageResource(R.drawable.icon_cell_dissed);
        else
            image_diss.setImageResource(R.drawable.icon_cell_diss);
    }
}
